<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/padrao.xhtml">
    <ui:define name="page">
        <ui:insert name="formGrowl">
            <p:growl id="growl" life="10000" />
        </ui:insert>
        <ui:insert name="confirmationDialog">
            <p:confirmDialog message="" appendToBody="true" header="${label['remove_title']}" severity="alert" widgetVar="confirmation">  
                <f:facet name="message">
                    <h:outputFormat id="msgConfirmation" value="${label['remove_message']}">
                        <f:param value="#{pMsgConfirmationObject}"/>
                        <f:param value="#{pMsgConfirmationDescription}"/>
                    </h:outputFormat> 
                </f:facet>
                <p:commandButton value="Sim" update=":formCad:tableRecords,:formCad:formMessages" action="#{pManagedBean.actionRemover}" oncomplete="confirmation.hide()"/>  
                <p:commandButton value="Não" onclick="confirmation.hide()" type="button" />   
            </p:confirmDialog> 
        </ui:insert>
        <h:form id="formCad">
            <ui:insert name="formMessages">
                <p:messages id="formMessages" closable="true"/>
            </ui:insert>
            <p:panel id="panelCadastro" header="#{pPageTitle}" style="border:0px">
                <ui:insert name="buttons">
                    <p:commandButton icon="ui-icon-document" accesskey="a" id="adicionar" immediate="true" action="#{pManagedBean.actionNovo}" 
                                     value="${label['btnAdicionar.label']}"/>
                    <p:tooltip for="adicionar">#{label['btnAdicionar.tooltip']}</p:tooltip>
                    <p:spacer width="5"/>
                </ui:insert>
                <br/>
                <br/>
                <h:panelGrid id="panelFields" >
                    <p:dataTable id="tableRecords" emptyMessage="Nenhum registro encontrado"
                                 selection="#{pTarget}" rowKey="#{obj.id}" value="#{pListaRecords}" var="obj" rows="10"
                                 paginator="true"  rowsPerPageTemplate="10,20,30,40,50" paginatorPosition="bottom"
                                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">                        
                        <ui:insert name="dataTable"></ui:insert>
                        <ui:insert name="editColumns">
                            <p:column style="width:1%" exportable="false">
                                <p:commandLink id="remover" title="Excluir" oncomplete="confirmation.show()" update=":msgConfirmation">
                                    <f:setPropertyActionListener value="#{obj}" target="#{pTarget}"/>
                                    <h:graphicImage library="imagens" name="remover.gif"/>
                                </p:commandLink>
                            </p:column>
                        </ui:insert>
                    </p:dataTable>
                </h:panelGrid>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
